//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: AddingPersistentEventArgs.cs
//
//  Description: EventArgs used by the AddingPersistent event.
// 
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;

namespace Chili.Opf3.Caching
{
	/// <summary>
	/// EventArgs used by the AddingPersistent event of the <see cref="SimpleCacheManager">SimpleCacheManager</see> Class.
	/// </summary>
	public sealed class AddingPersistentEventArgs : EventArgs
	{
		private bool _cancel;
		private object _persistent;
		private DateTime _validUntil;

		/// <summary>
		/// Creates a new instance of the <see cref="AddingPersistentEventArgs">AddingPersistentEventArgs Class</see>.
		/// </summary>
		/// <param name="persistent">The persistent that is added.</param>
		/// <param name="validUntil">The time until the persistent is valid.</param>
		internal AddingPersistentEventArgs(object persistent, DateTime validUntil)
		{
			if (persistent == null)
				throw new ArgumentNullException("persistent");
			_persistent = persistent;
			_validUntil = validUntil;
		}

		/// <summary>
		/// Gets or sets whether to cancel the add to the cache for this persistent.
		/// </summary>
		public bool Cancel
		{
			get { return _cancel; }
			set { _cancel = value; }
		}

		/// <summary>
		/// Gets the persistent that is added to the cache.
		/// </summary>
		public object Persistent
		{
			get { return _persistent; }
		}

		/// <summary>
		/// Gets or sets the date and time until persistent is valid.
		/// </summary>
		public DateTime ValidUntil
		{
			get { return _validUntil; }
			set { _validUntil = value; }
		}
	}
}
